<!DOCTYPE html>
<!-- saved from url=(0052)http://getbootstrap.com/docs/4.0/examples/dashboard/ -->
<html lang="en"  xmlns:th="http://www.thymeleaf.org">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<meta name="description" content="">
		<meta name="author" content="">

		<title>Dashboard Template for Bootstrap</title>
		<!-- Bootstrap core CSS -->
		<link href="asserts/css/bootstrap.min.css" th:href="@{/webjars/bootstrap/4.5.0/css/bootstrap.css}" rel="stylesheet">

		<!-- Custom styles for this template -->
		<link href="../../static/asserts/css/dashboard.css" rel="stylesheet" th:href="@{/asserts/css/dashboard.css}">
		<style type="text/css">
			/* Chart.js */
			
			@-webkit-keyframes chartjs-render-animation {
				from {
					opacity: 0.99
				}
				to {
					opacity: 1
				}
			}
			
			@keyframes chartjs-render-animation {
				from {
					opacity: 0.99
				}
				to {
					opacity: 1
				}
			}
			
			.chartjs-render-monitor {
				-webkit-animation: chartjs-render-animation 0.001s;
				animation: chartjs-render-animation 0.001s;
			}
		</style>
		<style>
			#span_page{
				font-size: 30px;
				margin-left: 15px;

			}
			.span_select{
				font-size: 20px;
				color: black;
			}
		</style>
	</head>

	<body>
		<!--引入顶部栏-->
		<div th:replace="commons/bar::topbar"></div>
		<div class="container-fluid">
			<div class="row">
				<!--引入侧边栏-->
				<div th:replace="commons/bar::sidebar(activeUri='emps')"></div>
				<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
					<form action="#" method="get" th:action="@{/emps}">
						<p> <span class="span_select">姓名:</span> <input type="text" name="name">
							<span class="span_select">性别:</span> <input type="text" name="gender">
							<span class="span_select">部门:</span>
							<select type="" name=deptId>
								<option th:value="0">----请选择----</option>
								<option th:each="dept:${depts}" th:value="${dept.id}">[[${dept.id}+${dept.deptName}]]</option>
							</select>
							<button type="submit" class="btn btn-primary">查询</button>
						</p>
					</form>
					<h2><a class="btn btn-sm btn-success" th:href="@{/emp}">添加员工</a>
						<a class="btn btn-sm btn-danger" th:attr="uri=@{/emps}" id="delAll" href="#">删除选中</a>  </h2>
					<div class="table-responsive">
						<table class="table table-striped table-sm">
							<thead>
								<tr>
									<th><input type="checkbox" id="th_checkbox"></th>
									<th>序号</th>
									<th>编号</th>
									<th>姓名</th>
									<th>邮箱</th>
									<th>性别</th>
									<th>部门</th>
									<th>生日</th>
								</tr>
							</thead>
							<tbody>
							 	<form id="delSelected" action="#" method="post">
									<input type="hidden" name="_method" value="delete">
								<tr th:each="emp:${pb.list}">
									<td><input type="checkbox" class="td_checkbox" name="eid" th:value="${emp.id}"></td>
									<!--使用emp来遍历emps，所以其默认状态变量为：empStat,empStat.count实现循环时递增序号-->
									<td th:text="${empStat.count}"></td>
									<td th:text="${emp.id}"></td>
									<td th:text="${emp.name}"></td>
									<td th:text="${emp.email}"></td>
									<td th:text="${emp.gender}"></td>
									<td th:text="${emp.deptId}"></td>
									<td th:text="${#dates.format(emp.birth,'yyyy-MM-dd')}"></td>
									<td>
										<a class="btn btn-sm btn-primary" th:href="@{/emp/}+${emp.id}">编辑</a>
										<!--删除功能-->
										<button  class="btn btn-sm btn-danger deleteBtn" th:attr="uri=@{/emp/}+${emp.id}">删除</button>
									</td>
								</tr>
								</form>
							</tbody>
						</table>
						<div>
							<nav aria-label="Page navigation example">
								<ul class="pagination">
									<li class="page-item">
										<a class="page-link" href="#" th:href="@{/emps(currentPage=${pb.currentPage}-1,pageSize=7,name=${emp.name},gender=${emp.gender},deptId=${emp.deptId})}" aria-label="Previous">
											<span aria-hidden="true">&laquo;</span>
										</a>
									</li>
									<th:block th:each="page:${#numbers.sequence(1,pb.totalPage)}" >
									<li class="page-item " th:class="${(pb.currentPage==page)?'page-item active':'page-item'}"><a class="page-link" href="#" th:href="@{/emps(currentPage=${page},pageSize=7,name=${emp.name},gender=${emp.gender},deptId=${emp.deptId})}" th:text="${page}"></a></li>
									</th:block>
									<li class="page-item">
										<a class="page-link" href="#" th:href="@{/emps(currentPage=${pb.currentPage}+1,pageSize=7,name=${emp.name},gender=${emp.gender},deptId=${emp.deptId})}" aria-label="Next">
											<span aria-hidden="true">&raquo;</span>
										</a>
									</li>
									<li>
										<span id="span_page">共<span style="color: red">[[${pb.totalPage}]]</span>页，<span style="color: red">[[${pb.totalCount}]]</span>条记录</span>
									</li>
								</ul>
							</nav>
						</div>
					</div>
				</main>
				<form id="delForm" action="#" method="post">
					<input type="hidden" name="_method" value="delete">
				</form>
			</div>
		</div>

		<!-- Bootstrap core JavaScript
    ================================================== -->
		<!-- Placed at the end of the document so the pages load faster -->
		<script type="text/javascript" src="asserts/js/jquery-3.2.1.slim.min.js" th:src="@{/webjars/jquery/3.5.1/jquery.js}"></script>
		<script type="text/javascript" src="asserts/js/popper.min.js" th:src="@{/webjars/popper.js/1.16.0/popper.js}"></script>
		<script type="text/javascript" src="asserts/js/bootstrap.min.js" th:src="@{/webjars/bootstrap/4.5.0/js/bootstrap.js}"></script>

		<!-- Icons -->
		<script type="text/javascript" src="../../static/asserts/js/feather.min.js" th:href="@{/asserts/js/feather.min.js}"></script>
		<script>
			feather.replace()
		</script>

		<!-- Graphs -->
		<script type="text/javascript" src="../../static/asserts/js/Chart.min.js" th:href="@{/asserts/js/Chart.min.js}"></script>
		<script>
			var ctx = document.getElementById("myChart");
			var myChart = new Chart(ctx, {
				type: 'line',
				data: {
					labels: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
					datasets: [{
						data: [15339, 21345, 18483, 24003, 23489, 24092, 12034],
						lineTension: 0,
						backgroundColor: 'transparent',
						borderColor: '#007bff',
						borderWidth: 4,
						pointBackgroundColor: '#007bff'
					}]
				},
				options: {
					scales: {
						yAxes: [{
							ticks: {
								beginAtZero: false
							}
						}]
					},
					legend: {
						display: false,
					}
				}
			});
		</script>
		<script>
			/*删除功能*/
			$(".deleteBtn").click(function () {
				//删除当前员工
				if(confirm("你确定要删除吗？")){
					$("#delForm").attr("action",$(this).attr("uri")).submit();
					return false;
				}
			});
		</script>
		<script>
			/*全选功能*/
			$("#th_checkbox").click(function () {
				$(".td_checkbox").attr("checked", this.checked);
			});

			/*删除选中：给删除选中按钮绑定单击事件，点击提交表单，携带删除的员工id*/
			$("#delAll").click(function () {

				if(confirm("你确定要删除所有选中吗？")){

						$("#delSelected").attr("action",$(this).attr("uri")).submit();
						return false;

				}
			});

		</script>


	</body>

</html>